<?php

/**
 * Timer.php
 *
 * Holds class Timer
 *
 * @package Library
 */

/**
 * Timer
 *
 * Simple timer
 *
 * @package Library
 */
class Timer {

	/**
	 * Start time
	 * @var float $_start
	 */
	protected $_start;

	/**
	 * Constructor
	 *
	 * @return void
	 */
	public function __construct() {
		//
	}

	/**
	 * Starts timer
	 *
	 * @return Timer (fluent interface)
	 */
	public function start() {
		$this->_start = microtime(true);
	}

	/**
	 * Stops timer
	 *
	 * @return float
	 */
	public function stop() {
		return microtime(true) - $this->_start;
	}

	/**
	 * Returns string representation
	 *
	 * @return string
	 */
	public function __toString() {
		return (string) $this->stop();
	}

}